package com.kingre.et.dao.jpa;

import java.util.List;

import com.kingre.et.dao.IDimensioScoreDAO;
import com.kingre.et.model.DimensioScore;
import com.kingre.et.model.Dimensionality;
import com.kingre.et.model.User;

public class DimensioScoreDAOJPA extends GenericDAOJPA<DimensioScore, Integer> implements IDimensioScoreDAO {
    @Override
    @SuppressWarnings("unchecked")
    public List<DimensioScore> findByUser(User user) {
        return this.getJpaTemplate().find("FROM DimensioScore WHERE user = ? ORDER BY dimensionality.id", user);
    }

    @SuppressWarnings("unchecked")
    @Override
    public DimensioScore findByUserDimensionality(User user, Dimensionality dim) {
        List<DimensioScore> list = this.getJpaTemplate().find(
                "FROM DimensioScore WHERE user = ? AND dimensionality = ?", user, dim);
        return list != null && list.size() > 0 ? list.get(0) : null;
    }

}
